<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      @import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap");

      * {
        box-sizing: border-box;
      }
      body {
        height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #7d5fff;
      }
      .container {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: flex-end;
      }
      #search {
        position: absolute;
        right: 0px;
        top: 0px;
        width: 50px;
        height: 50px;
        font-size: 26px;
        border: 0px;
      }
      input {
        width: 50px;
        border: 0px;
        outline: 0px;
        height: 50px;
        padding: 15px;
        font-size: 26px;
        color: gray;
        transition: width 0.3s ease;
      }
      .container.ative input {
        width: 200px;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <input type="text" value="search..." />
      <button id="search" class="fas fa-search">11</button>
    </div>

    <script>
      const container = document.querySelector(".container");

      document.addEventListener("click", (event) => {
        if (!(event.target.tagName === "BUTTON")) {
          return;
        }
        container.classList.toggle("ative");
      });
    </script>
  </body>
</html>
